package com.example.game.service.impl;

import com.example.datasource.DataSourceType;
import com.example.datasource.MyDataSource;
import com.example.game.domain.mapper.HmUserMapper;
import com.example.game.domain.pojo.HmUser;
import com.example.game.service.Userservice;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserserviceImpl implements Userservice {
    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private HmUserMapper hmUserMapper;

    @MyDataSource(DataSourceType.Master)
    public int save(HmUser hmUser) {
        int i = hmUserMapper.insertSelective(hmUser);
        return i;
    }

    @MyDataSource(DataSourceType.Master)
    public HmUser getMaster(Integer id) {
        HmUser hmUser = hmUserMapper.selectByPrimaryKey(id);
        return hmUser;
    }

    @MyDataSource(DataSourceType.Slave)
    public HmUser getSlave(Integer id) {
        HmUser hmUser = hmUserMapper.selectByPrimaryKey(id);
        return hmUser;
    }
}
